package org.mat.ipaas.ucenter.service.api.system;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.mat.framework.lang.dto.MatApiResponse;
import org.mat.ipaas.ucenter.service.constant.CacheConstant;
import org.mat.ipaas.ucenter.service.dto.system.entity.SysDictItemDTO;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpServletRequest;
import java.util.Collections;
import java.util.Date;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @Author zhangweijian
 * @since 2018-12-28
 */
@Api(tags = "数据字典")
@FeignClient(name = "mat-ipaas-ucenter-service", contextId = "sys-dict-item-rest-api")
public interface SysDictItemRestAPI {

    /**
     * @param sysDictItemDTO
     * @param pageNo
     * @param pageSize
     * @return
     * @功能：查询字典数据
     */
    @RequestMapping(value = "/sys/dictItem/list", method = RequestMethod.GET)
    MatApiResponse<Page<SysDictItemDTO>> queryPageList(@SpringQueryMap SysDictItemDTO sysDictItemDTO,
                                                       @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                                       @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize);

    /**
     * @return
     * @功能：新增
     */
    //@RequiresPermissions("system:dict:item:add")
    @RequestMapping(value = "/sys/dictItem/add", method = RequestMethod.POST)
    @CacheEvict(value = {CacheConstant.SYS_DICT_CACHE, CacheConstant.SYS_ENABLE_DICT_CACHE}, allEntries = true)
    MatApiResponse<SysDictItemDTO> add(@RequestBody SysDictItemDTO sysDictItemDTO);

    /**
     * @param sysDictItemDTO
     * @return
     * @功能：编辑
     */
    //@RequiresPermissions("system:dict:item:edit")
    @RequestMapping(value = "/sys/dictItem/edit", method = {RequestMethod.POST})
    @CacheEvict(value = {CacheConstant.SYS_DICT_CACHE, CacheConstant.SYS_ENABLE_DICT_CACHE}, allEntries = true)
    MatApiResponse<SysDictItemDTO> edit(@RequestBody SysDictItemDTO sysDictItemDTO);

    /**
     * @param id
     * @return
     * @功能：删除字典数据
     */
    //@RequiresPermissions("system:dict:item:delete")
    @RequestMapping(value = "/sys/dictItem/delete", method = RequestMethod.DELETE)
    @CacheEvict(value = {CacheConstant.SYS_DICT_CACHE, CacheConstant.SYS_ENABLE_DICT_CACHE}, allEntries = true)
    MatApiResponse<SysDictItemDTO> delete(@RequestParam(name = "id", required = true) String id);

    /**
     * @param ids
     * @return
     * @功能：批量删除字典数据
     */
    //@RequiresPermissions("system:dict:item:deleteBatch")
    @RequestMapping(value = "/sys/dictItem/deleteBatch", method = RequestMethod.DELETE)
    @CacheEvict(value = {CacheConstant.SYS_DICT_CACHE, CacheConstant.SYS_ENABLE_DICT_CACHE}, allEntries = true)
    MatApiResponse<SysDictItemDTO> deleteBatch(@RequestParam(name = "ids", required = true) String ids);

    /**
     * 字典值重复校验
     *
     * @param sysDictItemDTO
     * 
     * @return
     */
    @RequestMapping(value = "/sys/dictItem/dictItemCheck", method = RequestMethod.GET)
    @ApiOperation("字典重复校验接口")
    MatApiResponse<Object> doDictItemCheck(@SpringQueryMap SysDictItemDTO sysDictItemDTO);

}
